package com.quan.server.client;

import com.mark.util.JsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;
import java.util.Map;

public class RestClient {
    private static Logger logger = LoggerFactory.getLogger(RestClient.class);
    private static Client client = ClientBuilder.newClient();

    public static Client getClient() {
        return client;
    }

    public static Map getConfigFromGamma() {
        try {
            Response response = getClient().target("http://youhuiquan.duapp.com/api/config")
                .request()
                .get(Response.class);
            Map config = response.readEntity(Map.class);
            return config;
        } catch (Exception e) {
            logger.error("", e);
            return null;
        }
    }
}
